package org.urchr.beorganized.api.impl.user;

import java.util.TimeZone;

import org.urchr.beorganized.api.base.Log;
import org.urchr.beorganized.api.base.PrivateBaseAPIServlet;
import org.urchr.beorganized.dao.NotesDAO;
import org.urchr.beorganized.dao.UsersDAO;
import org.urchr.beorganized.dao.XMLDocumentBuilder;
import org.urchr.beorganized.dao.errors.GeneralException;
import org.urchr.beorganized.dao.tables.User;

public class GetCurrentUser extends PrivateBaseAPIServlet {

	@Override
	protected void doProcessPrivate() throws GeneralException {
		User user = UsersDAO.getUser(userID);
		XMLDocumentBuilder doc = new XMLDocumentBuilder();
		Log.debug(this, "User "+user.getLogin()+" entered BeOrganized! (Via saved session)");
		user = UsersDAO.updateUserTimeZone(user);
		UsersDAO.userToNode(doc, doc.getRootElement("user"), user);
		sendNode(doc.getRootElement());
	}

}
